﻿using System;
using System.Collections.Generic;
using System.Text;
using Vortex;
using Vortex.Drawing;

namespace Vortex.Tutorials.DrawingPrimitives {

    ///<summary>Example of how to draw primitves using Vortex2D.NET canvas API. Currently available: line, rectangle, ellipse, polyline, polygon</summary>
    class DrawingPrimitives : Game {

        protected override void Render (Canvas2D canvas) {
            //Clear background before drawing
            canvas.Clear(new ColorU(10, 10, 10));

            //draw line from start point to end point
            canvas.DrawLine(20, 50, 200, 100, ColorU.White);

            //drawing rectangle settings left,top point and width,height
            canvas.DrawRect(20, 130, 150, 130, ColorU.Blue);

            //drawing ellipse specifiyng bounding rect parameters: left,top point and width,height
            canvas.DrawEllipse(20, 250, 250, 130, ColorU.LimeGreen);

            /*
             *  Vortex.Drawing.Vector2 class represent 2-dimensionaly point, offset in Vortex2D.NET engine
             *  It has rich functionality can be created from System.Drawing.Point, System.Drawing.PointF,
             *  System.Drawing.Size, System.Drawing.SizeF and converted into them with ToXXX() method.
             *  This class supports lot of useful methods and operators. It can added, multiplied, divided
             *  with other vectors and scalars.
             */
            Vector2[] polylinePoints = new Vector2[] {
                new Vector2(10, 25),
                new Vector2(new System.Drawing.SizeF(635, 20)),
                new Vector2(630, 470)
            };

            //Polyline can be drawn from array of vectors which represents point location
            canvas.DrawPolyline(polylinePoints, ColorU.Yellow);

            Vector2[] polygonPoints = new Vector2[] {
                new Vector2(400),
                new Vector2(45, 41) * 10,
                new Vector2(160, 170) + new Vector2(300, 300),
                new Vector2(-420, -420).Negative,
                new Vector2(new System.Drawing.PointF(340, 440))
            };

            //Polygon is similar to polyline but it closes line list connecting last and first point
            canvas.DrawPolygon(polygonPoints, ColorU.White);
            canvas.DrawPolygon(polygonPoints, 1, 3, ColorU.Red);

            //Methods with filling are pretty much the same
            canvas.DrawFilledRect(320, 80, 150, 130, ColorU.Red);
            //You can specify color transparency with ColorU.MultiplyAlpha method. 0.0f-fully transparent, 1.0f - opaque
            canvas.DrawFilledEllipse(320, 180, 200, 180, ColorU.Blue.MultiplyAlpha(0.75f));
        }

    }
}
